package com.ljd.controller;

import com.ljd.service.FileService;
import com.ljd.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.security.PublicKey;

@RestController
//@CrossOrigin
@RequestMapping("/eduoss/fileoss")
public class FileUploadController {

    @Autowired
    private FileService fileService;
    @PostMapping
    public R upload(MultipartFile file) {
        String upload = null;
        try {
            upload = fileService.upload(file);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return R.ok().data("url",upload);
    }
}
